import urlConfig from './config.js'

const request = {}
const appid = 'wx46e7ddae971c303a'

/**
 * 全局请求
 */
request.globalRequest = (url, method, data) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: urlConfig + url,
			method: method,
			data: data,
			header: {
				'Content-Type': 'application/json'
			},
			success(request) {
				resolve(request.data)
			},
			fail(error) {
				reject(error)
			},
			complete(c) {
				// 加载完成
				//uni.hideLoading();
			}
		})
	})
}

/**
 * 小程序id
 */
request.appid = appid

/**
 * 导出方法
 */
export default request
